package com.qf.book.service.ipml;

import com.qf.book.dao.UserDao;
import com.qf.book.dao.impl.UserDaoImpl;
import com.qf.book.domain.User;
import com.qf.book.service.UserService;

public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();
    @Override
    public User login(String username, String password) {
        User user = userDao.select(username, password);
        if (user == null){
            throw new RuntimeException("用户名或密码错误");
        }
        if (user.getFlag() == 0){
            throw new RuntimeException("用户没有激活,或激活已失效");
        }
        return user;
    }
}
